from PyQt5.QtCore import QUrl, QObject, pyqtSlot
from PyQt5.QtGui import QGuiApplication
from PyQt5.QtQuick import QQuickView
import pandas as pd

class MainClass(QObject):
    @pyqtSlot(str)    # 输入参数为str类型
    def openCsvFile(self, filePath):  #定义qml调用的函数
        csv_data = pd.read_csv(filePath)

if __name__ == '__main__':
    app = QGuiApplication([])
    view = QQuickView()
    mainClass = MainClass()
    context = view.rootContext()
    context.setContextProperty("mainClass", mainClass)
    view.engine().quit.connect(app.quit)
    view.setSource(QUrl('main.qml'))
    view.showMaximized()
    app.exec_()

